﻿//新增心得
var TrActivityCourseID;
var type;
var fnAdds = function () {
    TrActivityCourseID = "0000-0000-0000-0000";
    type = 1;
    document.getElementById("EditUIWindow").src = "../TR/EditTrStudyGain.aspx?ID=" + TrActivityCourseID + "&type=" + type + "&entity=<%=EntityName%>";
    YAHOO.example.container.dialog1.show();
}
//新增点评
var fnAddGains = function (key) {
    var oRecord;    
    var selectRows = myDataTable.getSelectedRows();
    if (selectRows.length != null && selectRows.length == 1) {
        oRecord = myDataTable.getRecordSet().getRecord(selectRows[0]);
        TrActivityCourseID = YAHOO.lang.dump(oRecord.getData("TrStudyGainID"));
        type = 3;
        document.getElementById("EditUIWindow").src = "../TR/EditTrStudyGain.aspx?ID=" + TrActivityCourseID + "&type=" + type + "&entity=<%=EntityName%>";
        YAHOO.example.container.dialog1.show();
    }
    else {
        alert("请选中一行活动记录做点评管理");
    }
}

//编辑点评
var fnGainEdits = function (key) {
    var oRecord;
    var selectRows = myDataTable.getSelectedRows();
    if (selectRows.length != null && selectRows.length == 1) {
        oRecord = myDataTable.getRecordSet().getRecord(selectRows[0]);
        TrActivityCourseID = YAHOO.lang.dump(oRecord.getData("TrStudyGainID"));
        type = 4;
        document.getElementById("EditUIWindow").src = "../TR/EditTrStudyGain.aspx?ID=" + TrActivityCourseID + "&type=" + type + "&entity=<%=EntityName%>";
        YAHOO.example.container.dialog1.show();
    }
    else {
        alert("请选中一行活动记录做点评管理");
    }
}
//编辑心得
var fnEdits = function () {
    var oRecord;
    var selectRows = myDataTable.getSelectedRows();
    if (selectRows.length != null && selectRows.length == 1) {
        oRecord = myDataTable.getRecordSet().getRecord(selectRows[0]);
        TrActivityCourseID = YAHOO.lang.dump(oRecord.getData("TrStudyGainID"));
        type = 2;
        document.getElementById("EditUIWindow").src = "../TR/EditTrStudyGain.aspx?ID=" + TrActivityCourseID + "&type=" + type + "&entity=<%=EntityName%>";
        YAHOO.example.container.dialog1.show();
    }
    else {
        alert("请选中一行活动记录做心得管理");
    }
}
//查看
var fnLooks = function () {
    var oRecord;
    var selectRows = myDataTable.getSelectedRows();
    if (selectRows.length != null && selectRows.length == 1) {
        oRecord = myDataTable.getRecordSet().getRecord(selectRows[0]);
        TrActivityCourseID = YAHOO.lang.dump(oRecord.getData("TrStudyGainID"));
        type = 5;
        document.getElementById("EditUIWindow3").src = "../TR/EditTrStudyGain.aspx?ID=" + TrActivityCourseID + "&type=" + type + "&entity=" + const_entityName;
        YAHOO.example.container.dialog5.show();
    }
    else {
        alert("请选中一行心得记录导出!");
    }
}
//删除
var SaveUrl;
var fnDeletes = function () {

    var list = this.mDataTable.getRecordSet()._records;
    var elist = [];
    var str;
    TrActivityCourseID = "";
    dl = [];
    if (list.length > 0) {
        for (var i = 0; i < list.length; i++) {
            //this.getRecordSet()._records[0]._oData["BarItem"]
            if (list[i]._oData["iSun_Selected"] == true) {
                TrActivityCourseID += "︾";
                TrActivityCourseID += list[i]._oData[const_entityID]
                dl.push(list[i]._sId); //获取行ID；
            }
        }
        type = 5;
        SaveUrl = "../TR/CourceShareList.aspx?ID=" + encodeURI(TrActivityCourseID) + "&type=" + type + "";
       
        YAHOO.example.container.dialog3.show();
    }
    else {
        alert("请选中一行记录!");
    }
}
//删除
function DeleteData() {
    YAHOO.util.Connect.asyncRequest('POST', SaveUrl, {
        success: function (res) {
            try {
                var str = res.responseText;
                if (str == "1") {
                    YAHOO.example.container.dialog3.hide();
                    alert("数据删除成功");
                    LoadData();
                }
                else {
                    alert(str + "\n" + "数据删除失败!");
                }
            }
            catch (e) {
            }
            finally {
            }
        },
        failure: function (error) {
            alert("数据错误：" + error.statusText);
        }
    }, null);
}
//双击事件
function CustomDbClick() {
    var oRecord;
    var selectRows = myDataTable.getSelectedRows();
    if (selectRows.length != null && selectRows.length == 1) {
        oRecord = myDataTable.getRecordSet().getRecord(selectRows[0]);
        TrActivityCourseID = YAHOO.lang.dump(oRecord.getData("TrStudyGainID"));
        type = 5;
        document.getElementById("EditUIWindow3").src = "../TR/EditTrStudyGain.aspx?ID=" + TrActivityCourseID + "&type=" + type + "&entity=" + const_entityName;
        YAHOO.example.container.dialog5.show();
    }
    else {
        alert("请选中一行心得记录导出!");
    }
}
//导出
var fnExports = function () {
}
//报表
var fnReports = function () {
}